const state = {
  number: 0,
  notification: null
}

const mutations = {
  ADD_NOTIFATION: (state, notification) => {
    state.notification = notification
    state.number += 1
  },
  MINUS_NOTIFICATION: (state) => {
    state.number -= 1
  },
  INIT_NOTIFICATION: (state, num) => {
    state.number = num
  },
  RESET_NOTIFICATION: (state) => {
    state.notification = null
  }
}

const actions = {
  addNotification({ commit }, notification) {
    commit('ADD_NOTIFATION', notification)
  },
  minusNotification({ commit }) {
    commit('MINUS_NOTIFICATION')
  },
  initNotification({ commit }, num) {
    commit('INIT_NOTIFICATION', num)
  },
  resetNotification({ commit }) {
    commit('RESET_NOTIFICATION')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
